class Error(Exception):
    id = 'E000'
    msg = 'Error'
    def __init__(self,value=None):
        if value:
            self.value = value
        else:
            self.value = self.msg
    def __repr__(self):
        return self.msg
    def __str__(self):
        return self.value
    
class AppNotInitializedError(Error):
    id = 'E000'
    msg = 'Application not initialized, contact administrator.'
class NoPrivilegeError(Error):
    id = 'E001'
    msg = 'No Privilege.'
    def __init__(self, role=None):
        if role:
            self.value = 'No Privilege, level %d needed.' % role
        else:
            self.value = msg
class NoDefaultThemeError(Error):
    id = 'E002'
    msg = 'No default theme.(Is application initialized?)'
class NoThisObjectError(Error):
    id = 'E003'
    msg = 'No this object in datastore.'
class ObjectExistsError(Error):
    id = 'E004'
    msg = 'Object has existsed in datastore.'
class ThemePathNotAvailableError(Error):
    id = 'E005'
    msg = 'The Theme Folder is not available.'
class ThemeNotIntegrityError(Error):
    id = 'E006'
    msg = 'The Theme is not integrity.'
class InvalidWidgetIdError(Error):
    id = 'E007'
    msg = 'Invalid widget id.'
class PageNotFoundError(Error):
    id = 'E404'
    msg = 'Page Not Found'
    
__ErrMsg__ = {
    NoPrivilegeError.id:NoPrivilegeError.msg,
    PageNotFoundError.id:PageNotFoundError.msg,
    }

def getErrMsg(id):
    if __ErrMsg__.has_key(id):
        return __ErrMsg__[id]
    else:
        return 'Unknown Error'
    
